package router

import (
	"boy-go/docs"
	demoHandler "boy-go/modules/demo/handler"
	generatorHandler "boy-go/modules/generator/handler"
	"boy-go/modules/system/handler"
	"boy-go/pkg/security"
	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

func AddRouter(gin *gin.Engine) {
	systemServer := gin.Group("/system", security.VerifyToken)
	monitorServer := gin.Group("/monitor", security.VerifyToken)
	toolServer := gin.Group("/tool", security.VerifyToken)
	demoServer := gin.Group("/demo", security.VerifyToken)
	registerSwagger(gin)
	handler.AddCaptchaRouter(gin)
	handler.AddSysLoginRouter(gin)
	handler.AddSysUserRouter(systemServer)
	handler.AddSysDeptRouter(systemServer)
	handler.AddSysPostRouter(systemServer)
	handler.AddSysMenuRouter(systemServer)
	handler.AddSysRoleRouter(systemServer)
	handler.AddSysConfigRouter(systemServer)
	handler.AddSysDictTypeRouter(systemServer)
	handler.AddSysDictDataRouter(systemServer)
	handler.AddSysNoticeRouter(systemServer)
	handler.AddSysLogininforRouter(monitorServer)
	handler.AddSysOperLogRouter(monitorServer)
    // 代码生成路由
	generatorHandler.AddGenTableRouter(toolServer)
    // 演示项目路由添加
	demoHandler.AddTCompanyRouter(demoServer)
	demoHandler.AddTSchoolRouter(demoServer)
}

// 注册Swagger 路由
func registerSwagger(r gin.IRouter) {
	docs.SwaggerInfo.BasePath = "/"
	docs.SwaggerInfo.Title = "管理后台接口"
	docs.SwaggerInfo.Description = "实现一个管理系统的后端API服务"
	docs.SwaggerInfo.Version = "1.0"
	docs.SwaggerInfo.Schemes = []string{"http", "https"}
	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
}
